/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package visualcbir.board;

import Grid.Cell.CellItemInterface;
import incVSM.nGramColl;
import java.io.Reader;
import java.util.ArrayList;
import java.util.List;


/**
 *
 * @author robertopinho
 */
public class Board   extends AbstractBoard {

    public Board(Reader reader, nGramColl nGColl) {
        super(reader, nGColl);
    }
    
    public Board() {
        
    }
    public List<CellItemInterface> getNeighbors(int i_row, int j_col) {
        List<CellItemInterface> neighList = new ArrayList<CellItemInterface>();
        for(int i =-1;i<2;i++){
            for(int j =-1;j<2;j++){
                if(i==0 && j==0) continue;
                List<CellItemInterface> itemNeighbors = getItems(i_row+i, j_col+j); 
                if (itemNeighbors != null) {
                    neighList.addAll(itemNeighbors);
                }
            }
        }
        
        
        return neighList;
    }

    //Add step distance
    public int getDistance(CellItemInterface item, CellItemInterface other) {
        return getDistance(item.getRow(), item.getCol(),   
                other.getRow(), other.getCol());
    }

    public int getDistance(int i, int j, int x, int y) {
        return getDistanceStep( i, j, x,  y);
    }
    
    protected  int getDistanceManhattan(int i, int j, int x, int y) {
        return Math.abs(i - x) +
                Math.abs(j - y);
    }
    
    protected int getDistanceStep(int i, int j, int x, int y) {
    //  min{|xi-xj| , |yi-yj|} + | |xi-xj| - |yi-yj| |    
        return Math.max(Math.abs(i - x),Math.abs(j - y));
    }

    


    
    
}


